<html>
<head><meta charset="utf-8"><title>cannot satisfy dependencies so `libc` only shows up once · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cannot.20satisfy.20dependencies.20so.20.60libc.60.20only.20shows.20up.20once.html">cannot satisfy dependencies so `libc` only shows up once</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="238164029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cannot%20satisfy%20dependencies%20so%20%60libc%60%20only%20shows%20up%20once/near/238164029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cannot.20satisfy.20dependencies.20so.20.60libc.60.20only.20shows.20up.20once.html#238164029">(May 10 2021 at 15:42)</a>:</h4>
<p>Hi,</p>
<p>I've recently hit this error message:</p>
<div class="codehilite"><pre><span></span><code>error: cannot satisfy dependencies so `libc` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
</code></pre></div>
<p>My codebase is a workspace of a handful of crates (some using libc), all with:</p>
<div class="codehilite"><pre><span></span><code> [lib]
 crate-type = [&quot;dylib&quot;]
</code></pre></div>
<p>And in <code>.cargo/config.toml</code> I have:</p>
<div class="codehilite"><pre><span></span><code>[build]
rustflags = [&quot;-Cprefer-dynamic&quot;]
</code></pre></div>
<p>I expected this to work. libc doesn't restrict the available crate types.</p>
<p>What am I missing?</p>



<a name="238167157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cannot%20satisfy%20dependencies%20so%20%60libc%60%20only%20shows%20up%20once/near/238167157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cannot.20satisfy.20dependencies.20so.20.60libc.60.20only.20shows.20up.20once.html#238167157">(May 10 2021 at 16:02)</a>:</h4>
<p>(Replied in DM. For those curious if an rlib crate is depended on by two dylib crates, it would get linked into both of them, which would cause linker errors if you depend on both dylibs.)</p>



<a name="238168865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cannot%20satisfy%20dependencies%20so%20%60libc%60%20only%20shows%20up%20once/near/238168865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cannot.20satisfy.20dependencies.20so.20.60libc.60.20only.20shows.20up.20once.html#238168865">(May 10 2021 at 16:12)</a>:</h4>
<p>Thanks again <span class="user-mention" data-user-id="133247">@bjorn3</span>.</p>
<p>I'm coming to the conclusion that, generally, mixing Rust dylibs is likely to  result in pain. As Bjorn explained in PM, I can restructure my repo so that only one dylib imports <code>libc</code> (the others would declare it <code>extern</code>), but there's not guarantee that I wouldn't see the same again for another dep later down the line. </p>
<p>It looks like it would be better if I made just one of my workspace crates a <code>cdylib</code> and have the rest as rlibs. This means moving all of the exported C ABI functions to the sole <code>cdylib</code> crate...</p>



<a name="238169354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cannot%20satisfy%20dependencies%20so%20%60libc%60%20only%20shows%20up%20once/near/238169354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cannot.20satisfy.20dependencies.20so.20.60libc.60.20only.20shows.20up.20once.html#238169354">(May 10 2021 at 16:15)</a>:</h4>
<p>That is also what I would recommend</p>



<a name="238170552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cannot%20satisfy%20dependencies%20so%20%60libc%60%20only%20shows%20up%20once/near/238170552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cannot.20satisfy.20dependencies.20so.20.60libc.60.20only.20shows.20up.20once.html#238170552">(May 10 2021 at 16:22)</a>:</h4>
<p>I wonder if we could improve the error message to save pain for other users?</p>
<p>It would have been nice if rustc could have said:</p>
<blockquote>
<p>The two independent dylib crates X and Y both depend on <code>libc</code>. This would result in symbol clashing at link time.</p>
</blockquote>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>